<!-- ElTreeNode.vue -->

<template>
  <li>
    <div @click="handleClick">{{ node.label }}</div>
    <ul v-if="node.children && node.children.length > 0">
      <el-tree-node v-for="child in node.children" :key="child.id" :node="child" @nodeClick="$emit('nodeClick', child)" />
    </ul>
  </li>
</template>

<script lang="ts">
import { defineComponent, PropType } from 'vue';
import { TreeNode } from './TreeNode';

export default defineComponent({
  props: {
    node: {
      type: Object as PropType<TreeNode>,
      required: true,
    },
  },
  methods: {
    handleClick() {
      // 处理节点点击事件
      this.$emit('nodeClick', this.node);
    },
  },
});
</script>
